package Controller;

import Model.*;
import java.util.*;

/**
 * Simpel test applikation, som bare bruges til debugging, indtil videre.
 * @author Martin, David, Jan & Claus, AIT
 * @version 1.0
 */
public class SimpleTestApp implements ChessConstants {
  private static byte board_King_in_middle[] = {
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, BK, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
  };

  private static byte board_King_in_corner[] = {
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    BK, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
  };

  private static byte board_King_at_edge[] = {
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, BK, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
  };

  private static byte board_King_with_pawns[] = {
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, BK, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, BP, BP, BP, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
    PN, PN, PN, PN, PN, PN, PN, PN,    00, 00, 00, 00, 00, 00, 00, 00,
  };

  private static byte board_temp[] = {
    00, 00, BP, 00, 00, WP, BP, 00,    00, 00, 00, 00, 00, 00, 00, 00,
    00, 00, 00, 00, 00, 00, 00, 00,    00, 00, 00, 00, 00, 00, 00, 00,
    00, 00, 00, 00, 00, 00, 00, 00,    00, 00, 00, 00, 00, 00, 00, 00,
    00, 00, 00, 00, 00, 00, BP, 00,    00, 00, 00, 00, 00, 00, 00, 00,
    00, 00, 00, 00, 00, WP, 00, 00,    00, 00, 00, 00, 00, 00, 00, 00,
    00, 00, 00, 00, 00, 00, 00, 00,    00, 00, 00, 00, 00, 00, 00, 00,
    00, BP, 00, 00, 00, WP, 00, 00,    00, 00, 00, 00, 00, 00, 00, 00,
    00, 00, 00, 00, 00, WP, BP, 00,    00, 00, 00, 00, 00, 00, 00, 00,
  };


  public static void main (String args[])
  {
    Board board = new Board(board_temp);
    MoveGenerator mg = new MoveGenerator(SIDE_BLACK);
    mg.setBoard(board);

    System.out.println (board);

    //LinkedList moveList = mg.genMoves();
    PriorityQueue<Move> moveQueue = mg.genMoves();
    System.out.println ("numOfMoves: " + moveQueue.size());

    Iterator it = moveQueue.iterator();
    while (it.hasNext()) {
      Move move = (Move)(it.next());
      System.out.println (move);
    }


    Move pawnPromotion = new Move ((byte)0x60, (byte)0x61, PIECE_QUEEN, PIECE_PAWN, (byte)0, Move.TYPE_PAWN_PROMOTION);
    board.doLegalMove(pawnPromotion, SIDE_BLACK);
    System.out.println();
    System.out.println (board);
  }
}
